#!/bin/bash

#package_name="io.flutter.examples.hello_world"
#package_name="com.example.flutter_demo"
package_name="com.example.kcomplex"
#package_name="org.example.project"
adb shell am force-stop ${package_name}
sleep 1s
script_dir=$(dirname "$(realpath "$0")")
timestamp=$(date +"%H%M_%S")
mkdir -p ${script_dir}/${timestamp}
cd ${script_dir}/${timestamp}


adb shell monkey -p ${package_name} -c android.intent.category.LAUNCHER 1
sleep 1s

function swipe() {
    adb shell input swipe 200 2000 200 0
}

python3 /Users/hubinbin/Library/Android/sdk/ndk/26.3.11579264/simpleperf/app_profiler.py --ndk_path /Users/hubinbin/Library/Android/sdk/ndk/26.3.11579264 -nb --app ${package_name} -r "-g --duration 5 -e cpu-cycles" &
sleep  4s
swipe
wait
python3 /Users/hubinbin/Library/Android/sdk/ndk/26.3.11579264/simpleperf/report_html.py

cd ${script_dir}
